package io.renren.midplat.fuseclick.model;

import com.alibaba.fastjson.annotation.JSONField;

import java.io.Serializable;
import java.util.Date;

/**
 * @Description
 * @Author haijun.zhang@luckincoffee.com
 * @Date 2018-08-05 15:32
 **/
public class OfferDTO implements Serializable{

    private static final long serialVersionUID = 1068221207780980098L;

    /**
     * id Offer id. It is required for updating.
     * * for Updating
     */
    private Integer id;

    /**
     * 广告主id 。默认26
     * * for Creating
     */
    @JSONField(name="advertiser_id")
    private Integer advertiserId = 26;

    /**
     * 广告名称 * 
     * * for Creating
     */
    private String name;

    /**
     * 广告状态 先写死为Active 有以下枚举
     * * for Creating
     * Active/Pending/Paused/Archived
     */
    private String status = "Pending";

    /**
     * 上游过期时间  eg:2018/09/01
     * * for Creating
     */
    @JSONField(name = "expire_date",format="yyyy/MM/dd")
    private Date expireDate;

    /**
     * 广告类型  默认Mobile
     * * for Creating
     * Desktop/Mobile/Tablet
     */
    private String type="Mobile";

    /**
     * 换算点 默认Download and Install
     * Email Submit/DOI/SOI/Download and Install/ etc.
     */
    @JSONField(name="conversion_point")
    private String conversionPoint="Download and Install";

    /**
     * 上游 广告预览地址 Preview Url, it must be a valid url
     */
    @JSONField(name="preview_url")
    private String previewUrl;

    /**
     * 最终URL  最后的需要拼接~~~｛TrackingLink｝ ???
     * for Creating
     * http://tracking.adinall.com/index.php?offer_id=55126&aff_id=89
     * &aff_sub1={tid}&source_id={sub_affid}&ios_idfa={device_id}&google_id={s2}
     */
    private String url;

    /**
     * 入口类型 * for Creating 默认Need Approval
     * 好转就转，不好转就写死
     * Public/Need Approval/Private
     */
    @JSONField(name="access_type")
    private String accessType;

    /**
     * 安全套接字  默认0
     * * for Creating
     * 0(by default): disable SSL
     * 1: enable SSL.
     */
    private Integer ssl = 0;

    /**
     * 平台回传地址 Postback
     * * for Creating
     * Server Postback URL/iFrame Pixel/Image Pixel
     * 需要可配置
     */
    @JSONField(name="tracking_protocol")
   private String trackingProtocol = "Server Postback URL";
   //private String trackingProtocol = "http://api.wondermars.com/pb?tid={aff_sub1}";

    /**
     * 货币 上游平台字段 {currency} 后续需要转换 当前默认都是美金
     * * for Creating
     * 需要比对一下LIST
     * Currency code. Please refer to Currency List.
     */
    private Integer currency = 1;

    /**
     * 结算类型 {pricing_type}
     * * for Creating
     * CPA/CPC/CPS/CPI/CPA+CPS/CPL
     */
    @JSONField(name="payout_type")
    private String payoutType;

    /**
     * 结算金额 {payout}*0.8
     * 参数可配置
     */
    private String payout;

    /**
     * 结算百分比 不填 Float
     * Payout percentage of CPS and CPA+CPS
     */
    @JSONField(name="payout_percent")
    private String payoutPercent;

    /**
     * 收入类型
     * RPA/RPC/RPS/RPI/RPA+RPS/RPL
     * CPC对应RPA  CPC对应RPC
     */
    @JSONField(name="revenue_type")
    private String revenueType;

    /**
     * 收入 Float {payout}
     */
    private String revenue;

    /**
     * Revenue percentage of RPS and RPA+RPS 不填
     * 收入百分比
     */
    @JSONField(name="revenue_percent")
    private String revenuePercent;

    /**
     * 是否需要安全Token 默认off
     * 0(by default): OFF
     * 1: ON
     */
    @JSONField(name="need_security_token")
    private Integer needSecurityToken = 0;

    /**
     * 是否必须 默认off
     * 0(by default): OFF
     * 1: ON
     */
    @JSONField(name="force_unique")
    private Integer forceUnique = 0;

    /**
     * Session 周期 默认 1 Week
     * * for Creating
     * Session LifeSpan: 1 Day/1 Week/2 Weeks/1 Month
     */
    @JSONField(name="session_lifespan")
    private String sessionLifespan = "1 Week";

    /**
     * 隐藏推荐人 默认OFF
     * 0(by default): OFF
     * 1: ON
     */
    @JSONField(name="hide_referrer")
    private Integer hideReferrer = 0;

    /**
     * 第二广告 不填
     * Secondary Offer id
     */
    @JSONField(name="secondary_offer")
    private Integer secondaryOffer;

    /**
     * 描述 有就填，没有不填
     * Offer description/Initial Event description.
     */
    private String description;

    /**
     * 限制约束  ？？？
     */
    private String restriction;

    /**
     * CAP:限额，每天的offer转化超过这个数就不转化了。
     * 是否需要Cap限制 on 按流量上限 默认1
     * * for Creating
     * 0(by default): OFF
     * 1: ON
     */
    @JSONField(name="has_cap_limit")
    private Integer hasCapLimit = 1;

    /**
     * cap类型 {Conversion} 转换 ???
     * 曹流量类型:预算/转换
     * Traffic Cao type: Budget/Conversion
     * 不为空的话JSON转换一下
     */
    @JSONField(name="cap_type")
    private String capType = "Conversion";

    /**
     * cap事件范围  ???
     * Traffic Cap range: All/Initial
     * All(by default)
     */
    @JSONField(name="cap_event_range")
    private String capEventRange;

    /**
     * CAP全部限制 ???
     * -1: no limit
     */
    @JSONField(name="cap_overall_limit")
    private Integer capOverallLimit;

    /**
     * CAP间隔  默认Daily
     * Daily/Weekly/Monthly
     */
    @JSONField(name="cap_interval")
    private String capInterval = "Daily";

    /**
     * CAP间隔限制 默认100  上游有就用上游的
     * -1: no limit
     * *cap_interval is required for this
     */
    @JSONField(name="cap_interval_limit")
    private Integer capIntervalLimit = 100;

    /**
     * CAP分公司全部显示 ???
     * -1: no limit
     */
    @JSONField(name="cap_affiliate_overall_limit")
    private Integer capAffiliateOverallLimit;

    /**
     * CAP分公司间隔 ????
     * Daily/Weekly/Monthly
     */
    @JSONField(name="cap_affiliate_interval")
    private String capAffiliateInterval;

    /**
     * CAP分公司间隔显示 ？？？
     * *cap_affiliate_interval is required for this
     * -1: no limit
     */
    @JSONField(name="cap_affiliate_interval_limit")
    private Integer capAffiliateIntervalLimit;

    /**
     * 使目标提供设备 默认ON
     * * for Creating
     * 0(by default): OFF
     * 1: ON
     * * for Creating
     */
    @JSONField(name="device_targeting")
    private Integer deviceTargeting = 1;

    /**
     * 设备规则 IOS/Android 需要拼接 数组 ???
     * Array of Device targeting rules:
     device_rules[0]=0:Device Brand:ASUS;BlackBerry
     Block the traffic from Device Brand: ASUS and BlackBerry
     device_rules[1]=1:OS:iOS;Windows phone
     Allow the traffic from OS: iOS and Windows Phone
     Special for OS version:
     device_rules[1]=1:OS:iOS(10.3-11.4);Windows phone(-8);android(6-)
     Allow the traffic from iOS 10.3 to iOS 11.4, Windows phone 8 and below, android 6 and above
     Android:
     "1","2","3.0","3.1","3.2","4.0","4.1","4.2","4.3","4.4","5.0","5.1","6.0","7.0","7.1.0","7.1.1","7.2","8","8.1","9"
     iOS:
     "6.0","7.0","7.1","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","10.0","10.1","10.2.0","10.3.0","10.3.1","10.3.2","11.0","11.0.2","11.0.3","11.3","11.4","12"
     Windows Phone:
     "7","8","10"
     */
    @JSONField(name="device_rules")
    private String deviceRules;

    /**
     * 设备定向提供id ???
     * Device Targeting redirect offer id
     */
    @JSONField(name="device_redirect_offer_id")
    private Integer deviceRedirectOfferId;

    /**
     * 使提供地理定位: 默认ON
     * * for Creating
     * Enable Offer Geo targeting:
     * 0(by default): OFF
     * 1: ON
     */
    @JSONField(name="geo_targeting")
    private Integer geoTargeting = 1;

    /**
     * 地理位置类型 默认1
     * Geo类型，包括国家或排除国:
     * Geo Type, Include Country or Exclude Country:
     * 1: include
     * 0: exclude
     * INCLUDE accepts regions(states&cities)
     * EXCLUDE accepts countries only
     */
    @JSONField(name="geo_type")
    private Integer geoType = 1;

    /**
     * 地理国家集合 数组 ???
     * Array of Geo targeting rules:
     geo_countries [0]= US:1:TX
     Allow the traffic from TX of US
     geo_countries [1]= CA:0:BC;NT;NU
     Block the traffic from BC,NT,NU of CA
     地理定位规则数组:
     geo_countries[0]=我们:1:TX
     允许我们TX的交通
     geo_countries[1]= CA:0:公元前;NT,怒
     阻止来自BC、NT、CA的流量
     */
    @JSONField(name="geo_countries")
    private String geoCountries;

    public String getGeoCountries() {
        return geoCountries;
    }

    public void setGeoCountries(String geoCountries) {
        this.geoCountries = geoCountries;
    }

    /**
     * 使执行地理定位: 默认ON
     * 0(by default): OFF
     * 1: ON
     */
    @JSONField(name="geo_enforce")
    private Integer geoEnforce = 1;

    /**
     * 地理定位定向类型: ???
     * Geo targeting redirect type:
     * 0: offer
     * 1: geo offer group
     */
    @JSONField(name="geo_redirect_type")
    private Integer geoRedirectType;

    /**
     * 得到目标定向id: ???
     * 根据“geo_redirect_type”提供的报价id或报价geo组id
     *
     */
    @JSONField(name="geo_redirect_target_id")
    private Integer geoRedirectTargetId;

    /**
     * 解析previewLink
     */
    @JSONField(name="app_id")
    private String appId;

    /**
     * 提供类别的列表。 ???
     */
    private String categories;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getAdvertiserId() {
        return advertiserId;
    }

    public void setAdvertiserId(Integer advertiserId) {
        this.advertiserId = advertiserId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Date getExpireDate() {
        return expireDate;
    }

    public void setExpireDate(Date expireDate) {
        this.expireDate = expireDate;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getConversionPoint() {
        return conversionPoint;
    }

    public void setConversionPoint(String conversionPoint) {
        this.conversionPoint = conversionPoint;
    }

    public String getPreviewUrl() {
        return previewUrl;
    }

    public void setPreviewUrl(String previewUrl) {
        this.previewUrl = previewUrl;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getAccessType() {
        return accessType;
    }

    public void setAccessType(String accessType) {
        this.accessType = accessType;
    }

    public Integer getSsl() {
        return ssl;
    }

    public void setSsl(Integer ssl) {
        this.ssl = ssl;
    }

    public String getTrackingProtocol() {
        return trackingProtocol;
    }

    public void setTrackingProtocol(String trackingProtocol) {
        this.trackingProtocol = trackingProtocol;
    }

    public Integer getCurrency() {
        return currency;
    }

    public void setCurrency(Integer currency) {
        this.currency = currency;
    }

    public String getPayoutType() {
        return payoutType;
    }

    public void setPayoutType(String payoutType) {
        this.payoutType = payoutType;
    }

    public String getPayout() {
        return payout;
    }

    public void setPayout(String payout) {
        this.payout = payout;
    }

    public String getPayoutPercent() {
        return payoutPercent;
    }

    public void setPayoutPercent(String payoutPercent) {
        this.payoutPercent = payoutPercent;
    }

    public String getRevenueType() {
        return revenueType;
    }

    //CPA · CPC · CPS · CPA+CPS
    public void setRevenueType(String revenueType) {
        if(revenueType.equals("CPA")){
            this.revenueType = "RPA";
        } else if(revenueType.equals("CPC")){
            this.revenueType = "RPC";
        }else if(revenueType.equals("CPS")){
            this.revenueType = "RPS";
        }else if(revenueType.equals("CPA+CPS")){
            this.revenueType = "RPA+RPS";
        }
    }

    public String getRevenue() {
        return revenue;
    }

    public void setRevenue(String revenue) {
        this.revenue = revenue;
    }

    public String getRevenuePercent() {
        return revenuePercent;
    }

    public void setRevenuePercent(String revenuePercent) {
        this.revenuePercent = revenuePercent;
    }

    public Integer getNeedSecurityToken() {
        return needSecurityToken;
    }

    public void setNeedSecurityToken(Integer needSecurityToken) {
        this.needSecurityToken = needSecurityToken;
    }

    public Integer getForceUnique() {
        return forceUnique;
    }

    public void setForceUnique(Integer forceUnique) {
        this.forceUnique = forceUnique;
    }

    public String getSessionLifespan() {
        return sessionLifespan;
    }

    public void setSessionLifespan(String sessionLifespan) {
        this.sessionLifespan = sessionLifespan;
    }

    public Integer getHideReferrer() {
        return hideReferrer;
    }

    public void setHideReferrer(Integer hideReferrer) {
        this.hideReferrer = hideReferrer;
    }

    public Integer getSecondaryOffer() {
        return secondaryOffer;
    }

    public void setSecondaryOffer(Integer secondaryOffer) {
        this.secondaryOffer = secondaryOffer;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getRestriction() {
        return restriction;
    }

    public void setRestriction(String restriction) {
        this.restriction = restriction;
    }

    public Integer getHasCapLimit() {
        return hasCapLimit;
    }

    public void setHasCapLimit(Integer hasCapLimit) {
        this.hasCapLimit = hasCapLimit;
    }

    public String getCapType() {
        return capType;
    }

    public void setCapType(String capType) {
        this.capType = capType;
    }

    public String getCapEventRange() {
        return capEventRange;
    }

    public void setCapEventRange(String capEventRange) {
        this.capEventRange = capEventRange;
    }

    public Integer getCapOverallLimit() {
        return capOverallLimit;
    }

    public void setCapOverallLimit(Integer capOverallLimit) {
        this.capOverallLimit = capOverallLimit;
    }

    public String getCapInterval() {
        return capInterval;
    }

    public void setCapInterval(String capInterval) {
        this.capInterval = capInterval;
    }

    public Integer getCapIntervalLimit() {
        return capIntervalLimit;
    }

    public void setCapIntervalLimit(Integer capIntervalLimit) {
        this.capIntervalLimit = capIntervalLimit;
    }

    public Integer getCapAffiliateOverallLimit() {
        return capAffiliateOverallLimit;
    }

    public void setCapAffiliateOverallLimit(Integer capAffiliateOverallLimit) {
        this.capAffiliateOverallLimit = capAffiliateOverallLimit;
    }

    public String getCapAffiliateInterval() {
        return capAffiliateInterval;
    }

    public void setCapAffiliateInterval(String capAffiliateInterval) {
        this.capAffiliateInterval = capAffiliateInterval;
    }

    public Integer getCapAffiliateIntervalLimit() {
        return capAffiliateIntervalLimit;
    }

    public void setCapAffiliateIntervalLimit(Integer capAffiliateIntervalLimit) {
        this.capAffiliateIntervalLimit = capAffiliateIntervalLimit;
    }

    public Integer getDeviceTargeting() {
        return deviceTargeting;
    }

    public void setDeviceTargeting(Integer deviceTargeting) {
        this.deviceTargeting = deviceTargeting;
    }

    public String getDeviceRules() {
        return deviceRules;
    }

    public void setDeviceRules(String deviceRules) {
        this.deviceRules = deviceRules;
    }

    public Integer getDeviceRedirectOfferId() {
        return deviceRedirectOfferId;
    }

    public void setDeviceRedirectOfferId(Integer deviceRedirectOfferId) {
        this.deviceRedirectOfferId = deviceRedirectOfferId;
    }

    public Integer getGeoTargeting() {
        return geoTargeting;
    }

    public void setGeoTargeting(Integer geoTargeting) {
        this.geoTargeting = geoTargeting;
    }

    public Integer getGeoType() {
        return geoType;
    }

    public void setGeoType(Integer geoType) {
        this.geoType = geoType;
    }
//
//    public String getGeoCountries() {
//        return geoCountries;
//    }
//
//    public void setGeoCountries(String geoCountries) {
//        this.geoCountries = geoCountries;
//    }

    public Integer getGeoEnforce() {
        return geoEnforce;
    }

    public void setGeoEnforce(Integer geoEnforce) {
        this.geoEnforce = geoEnforce;
    }

    public Integer getGeoRedirectType() {
        return geoRedirectType;
    }

    public void setGeoRedirectType(Integer  geoRedirectType) {
        this.geoRedirectType = geoRedirectType;
    }

    public Integer getGeoRedirectTargetId() {
        return geoRedirectTargetId;
    }

    public void setGeoRedirectTargetId(Integer  geoRedirectTargetId) {
        this.geoRedirectTargetId = geoRedirectTargetId;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        if(appId.startsWith("https://play.google.com")){
            String image = appId.substring(appId.lastIndexOf("id=")+3);
            this.appId = image;
        }
        if(appId.startsWith("https://itunes.apple.com")){
            String image = appId.substring(appId.lastIndexOf("/app/id")+5);
            this.appId = image;
        }

    }

    public String getCategories() {
        return categories;
    }

    public void setCategories(String categories) {
        this.categories = categories;
    }

    @Override
    public String toString() {
        return "OfferDTO{" +
                "id=" + id +
                ", advertiserId=" + advertiserId +
                ", name='" + name + '\'' +
                ", status='" + status + '\'' +
                ", expireDate=" + expireDate +
                ", type='" + type + '\'' +
                ", conversionPoint='" + conversionPoint + '\'' +
                ", previewUrl='" + previewUrl + '\'' +
                ", url='" + url + '\'' +
                ", accessType='" + accessType + '\'' +
                ", ssl=" + ssl +
                ", trackingProtocol='" + trackingProtocol + '\'' +
                ", currency=" + currency +
                ", payoutType='" + payoutType + '\'' +
                ", payout='" + payout + '\'' +
                ", payoutPercent='" + payoutPercent + '\'' +
                ", revenueType='" + revenueType + '\'' +
                ", revenue='" + revenue + '\'' +
                ", revenuePercent='" + revenuePercent + '\'' +
                ", needSecurityToken=" + needSecurityToken +
                ", forceUnique=" + forceUnique +
                ", sessionLifespan='" + sessionLifespan + '\'' +
                ", hideReferrer=" + hideReferrer +
                ", secondaryOffer=" + secondaryOffer +
                ", description='" + description + '\'' +
                ", restriction='" + restriction + '\'' +
                ", hasCapLimit=" + hasCapLimit +
                ", capType='" + capType + '\'' +
                ", capEventRange='" + capEventRange + '\'' +
                ", capOverallLimit=" + capOverallLimit +
                ", capInterval='" + capInterval + '\'' +
                ", capIntervalLimit=" + capIntervalLimit +
                ", capAffiliateOverallLimit=" + capAffiliateOverallLimit +
                ", capAffiliateInterval='" + capAffiliateInterval + '\'' +
                ", capAffiliateIntervalLimit=" + capAffiliateIntervalLimit +
                ", deviceTargeting=" + deviceTargeting +
                ", deviceRules='" + deviceRules + '\'' +
                ", deviceRedirectOfferId=" + deviceRedirectOfferId +
                ", geoTargeting=" + geoTargeting +
                ", geoType=" + geoType +
            //    ", geoCountries='" + geoCountries + '\'' +
                ", geoEnforce=" + geoEnforce +
                ", geoRedirectType=" + geoRedirectType +
                ", geoRedirectTargetId=" + geoRedirectTargetId +
                ", appId='" + appId + '\'' +
                ", categories='" + categories + '\'' +
                '}';
    }

}
